'use strict';

const Controller = require('egg').Controller;

class CommentController extends Controller {
  async commentList() {
    const { ctx, logger } = this
    const { tid, limit, offset } = ctx.request.body
    
    logger.info("/comment/commentList 入参======>>" + JSON.stringify(ctx.request.body))

    ctx.body = await ctx.service.comment.selectComments(
        tid, 
        limit, 
        offset
      )
  
    logger.info("/comment/commentList 出参======>>" + JSON.stringify(ctx.body))
  }

  async postComment() {
    const { ctx, logger } = this
    const { tid, rid, puid, ruid, comment, } = ctx.request.body
    
    logger.info("/comment/postComment 入参======>>" + JSON.stringify(ctx.request.body))

    ctx.body = await ctx.service.comment.addComment(
        tid, 
        rid,
        puid, 
        ruid,
        comment,
      )
  
    logger.info("/comment/postComment 出参======>>" + JSON.stringify(ctx.body))
  }
}

module.exports = CommentController;
